<h2>Sửa trạng thái đơn đặt hàng</h2>
<script type="text/javascript">
	function Huy()
	{
		location.href = "./index.php?act=4";	
	}
</script>
<?php
	if(!isset($_GET["id"]))
	{
		header("location:./index.php?act=4");	
	}
	
	$id = $_GET["id"];
	$sql = "SELECT d.ma, n.tenguoidung, d.ngay, t.ten, n.diachi FROM dondathang d, nguoidung n, trangthaidondathang t WHERE d.manguoidung = n.manguoidung AND d.matrangthai = t.ma AND d.ma = ".$id;
	$result = DataProvider::ExecuteQuery($sql);
	$row = mysql_fetch_array($result);
?>
		<div class="form">
         <form action="./pages/dondathang/xlSua.php" method="post">
                <fieldset>
                	<input type="hidden" name="ma" value="<?php echo $row["ma"]; ?>" />
                    <dl>
                        <dt><label for="email">Mã đơn đặt hàng:</label></dt>
                        <dd><?php echo $row["ma"]; ?></dd>
                    </dl>
                    <dl>
                        <dt><label for="email">Tên người đặt hàng:</label></dt>
                        <dd><?php echo $row["tenguoidung"]; ?></dd>
                    </dl>
                    <dl>
                        <dt><label for="email">Địa chỉ:</label></dt>
                        
                        <dd><?php echo $row["diachi"]; ?></dd>
                    </dl>
                    <dl>
                        <dt><label for="email">ngày đặt hàng:</label></dt>
                        <dd><?php echo $row["ngay"]; ?></dd>
                    </dl>
                    <dl>
                        <dt><label for="gender">Trạng thái đặt hàng:</label></dt>
                        <dd>
                            <select size="1" name="trangthai" id="">
                            	<?php
									$sql = "SELECT * FROM trangthaidondathang";
									$result = DataProvider::ExecuteQuery($sql);
									while($dong = mysql_fetch_array($result))
									{
										if($dong["ma"] == $row["matrangthai"])
										{
											?>
                                        	<option value="<?php echo $dong["ma"]; ?>" selected="selected"><?php echo $dong["ten"];?></option>
                                        	<?php
										}
										else
										{
											?>
                                        	<option value="<?php echo $dong["ma"]; ?>"><?php echo $dong["ten"];?></option>
                                        	<?php
										}
												
									}
								?>
                            </select>
                        </dd>
                    </dl>
                    
                     <dl class="submit">
                    	<input type="submit" name="submit" id="submit" value="Cập nhật" />
                        <input type="button"  value="Hủy thao tác" onClick="Huy();" />
                     </dl>
                     
                </fieldset>
                
         </form>
         </div>
<h2>Chi tiết đơn đặt hàng</h2>
<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
    <thead>
    	<tr>
            <th scope="col" class="rounded-company">STT</th>
            <th scope="col" class="rounded">Tên sản phẩm</th>
            <th scope="col" class="rounded">Số lượng</th>
            <th scope="col" class="rounded-q4">Giá bán</th>
        </tr>
    </thead>
        <tfoot>
    	<tr>
			<td class="rounded-foot-left">&nbsp;</td>
            <td colspan="2">&nbsp;</td>
        	<td class="rounded-foot-right">&nbsp;</td>
        </tr>
    </tfoot>
    <tbody>
<?php
	$sql = "SELECT dt.tendt, c.soluong, c.giaban FROM dt, chitietdondathang c WHERE c.madondathang = ".$row["ma"]." AND c.madt = dt.madt";
	$result = DataProvider::ExecuteQuery($sql);
	$stt = 1;
	while($row = mysql_fetch_array($result))
	{
		?>
        	<tr>
				<td><?php echo $stt++; ?></td>
                <td><?php echo $row["tendt"]; ?></td>
                <td><?php echo $row["soluong"]; ?></td>
                <td><?php echo $row["giaban"]; ?></td>
            </tr>
        <?php
	}
?>		 

	</tbody>
</table>
         